home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.4)
-
- '''Psyco general support module.
-
- For internal use.
- '''
- import sys
- import _psyco
- import __builtin__
- error = _psyco.error
-
- class warning(Warning):
- pass
-
- _psyco.NoLocalsWarning = warning
-
- def warn(msg):
- warn = warn
- import warnings
- warn(msg, warning, stacklevel = 2)
-
- __version__ = 17039600
- if _psyco.PSYVER != __version__:
- raise error, 'version mismatch between Psyco parts, reinstall it'
-
- VERSION_LIMITS = [
- 33619968,
- 33685504,
- 33686016,
- 33751040,
- 33816576]
- PYTHON_SUPPORT = hasattr(_psyco, 'turbo_code')
- if hasattr(_psyco, 'ALL_CHECKS') and hasattr(_psyco, 'VERBOSE_LEVEL'):
- print >>sys.stderr, 'psyco: running in debugging mode on %s' % _psyco.PROCESSOR
-
-
- class Frame:
- pass
-
-
- class PythonFrame(Frame):
-
- def __init__(self, frame):
- self.__dict__.update({
- '_frame': frame })
-
-
- def __getattr__(self, attr):
- if attr == 'f_back':
-
- try:
- result = embedframe(_psyco.getframe(self._frame))
- except ValueError:
- result = None
- except error:
- warn('f_back is skipping dead Psyco frames')
- result = self._frame.f_back
-
- self.__dict__['f_back'] = result
- return result
- else:
- return getattr(self._frame, attr)
-
-
- def __setattr__(self, attr, value):
- setattr(self._frame, attr, value)
-
-
- def __delattr__(self, attr):
- delattr(self._frame, attr)
-
-
-
- class PsycoFrame(Frame):
-
- def __init__(self, tag):
- self.__dict__.update({
- '_tag': tag,
- 'f_code': tag[0],
- 'f_globals': tag[1] })
-
-
- def __getattr__(self, attr):
- if attr == 'f_back':
-
- try:
- result = embedframe(_psyco.getframe(self._tag))
- except ValueError:
- result = None
- except:
- None<EXCEPTION MATCH>ValueError
-
-
- None<EXCEPTION MATCH>ValueError
- if attr == 'f_lineno':
- result = self.f_code.co_firstlineno
- elif attr == 'f_builtins':
- result = self.f_globals['__builtins__']
- elif attr == 'f_restricted':
- result = self.f_builtins is not __builtins__
- elif attr == 'f_locals':
- raise AttributeError, 'local variables of functions run by Psyco cannot be accessed in any way, sorry'
- else:
- raise AttributeError, "emulated Psyco frames have no '%s' attribute" % attr
- self.__dict__[attr] = result
- return result
-
-
- def __setattr__(self, attr, value):
- raise AttributeError, 'Psyco frame objects are read-only'
-
-
- def __delattr__(self, attr):
- if attr == 'f_trace':
- return None
-
- raise AttributeError, 'Psyco frame objects are read-only'
-
-
-
- def embedframe(result):
- if type(result) is type(()):
- return PsycoFrame(result)
- else:
- return PythonFrame(result)
-
-
- def _getframe(depth = 0):
- '''Return a frame object from the call stack. This is a replacement for
- sys._getframe() which is aware of Psyco frames.
-
- The returned objects are instances of either PythonFrame or PsycoFrame
- instead of being real Python-level frame object, so that they can emulate
- the common attributes of frame objects.
-
- The original sys._getframe() ignoring Psyco frames altogether is stored in
- psyco._getrealframe(). See also psyco._getemulframe().'''
- return embedframe(_psyco.getframe(depth + 1))
-
-
- def _getemulframe(depth = 0):
- '''As _getframe(), but the returned objects are real Python frame objects
- emulating Psyco frames. Some of their attributes can be wrong or missing,
- however.'''
- return _psyco.getframe(depth + 1, 1)
-
-
- def patch(name, module = __builtin__):
- f = getattr(_psyco, name)
- org = getattr(module, name)
- if org is not f:
- setattr(module, name, f)
- setattr(_psyco, 'original_' + name, org)
-
-
- _getrealframe = sys._getframe
- sys._getframe = _getframe
- patch('globals')
- patch('eval')
- patch('execfile')
- patch('locals')
- patch('vars')
- patch('dir')
- patch('input')
- _psyco.original_raw_input = raw_input
- __builtin__.__in_psyco__ = 0 == 1
- if hasattr(_psyco, 'compact'):
- import kdictproxy
- _psyco.compactdictproxy = kdictproxy.compactdictproxy
-
-